import React, { Component } from 'react';
import { Link } from 'react-router';
import { inject, observer } from 'mobx-react';
import { Button, Icon } from 'antd'
import { createForm } from 'rc-form';
import Ajax from 'lib/Ajax'
import ListMixin from 'mixin/list'
import EditModule from './editModule'

@inject('appStore')
@observer
class ModuleName extends ListMixin {
  constructor(props) {
    super(props);
    this.listApi = '/testing/list';
    this.state = Object.assign({
      city: '',
      experienceId: ''
    }, this.state);
    this.api = {
      list: '/admin/testing/list',
      get: '',
      save: '',
      delete: '/admin/testing/delete'
    }
    this.itemKey = 'testingId';
    this.columns = [{
      title: '测验id',
      dataIndex: 'testingId'
    },{
      title: '测验标题',
      dataIndex: 'title'
    },{
      title: '分类',
      dataIndex: 'categoryId',
      render: text => <span>{this.props.appStore.getNameById('coureseTypeEn', text)}</span>
    },{
      title: '发布时间',
      dataIndex: 'createTime'
    }, {
      title: '操作',
      dataIndex: 'action',
      render: (text, item) => <span className="action">
        <a href="javascript:;" onClick={()=>{
          this.operate('edit', item[this.itemKey]);
        }}><Icon type="edit"/></a>
        <a href="javascript:;" onClick={()=>{
          this.doDelete(item[this.itemKey]);
        }}><Icon type="delete"/></a>
      </span>
    }];
  }

  renderEdit = () => {
    return <EditModule
              visible={ this.state.visible }
              onOk={ this.editOk }
              onCancel={ this.editCancel }
              type={ this.state.editType }
              editId={ this.state.editId }
            />
  }
}


module.exports = ModuleName
